package com.ljs.view.role
{
	import com.ljs.control.MainContent;
	import com.ljs.define.CharStateDefine;
	import com.ljs.define.CharTypeDefine;
	import com.ljs.view.role.Role1;
	import com.ljs.view.role.Role2;
	import com.ljs.view.role.Role3;
	import com.ljs.view.role.Role4;
	
	import flash.display.MovieClip;

	public class Role extends MovieClip
	{
		private var _content:MainContent;
		private var _mc:MovieClip;
		private var _state:int;
		public function Role()
		{
			
		}
		
		public function setContent(c:MainContent)
		{
			_content=c;
		}
		
		public function create()
		{
			destroy();
			switch(_content.mainVo.charType)
			{
				case CharTypeDefine.CHAR_1:
					_mc=new Role1();
					break;
				case CharTypeDefine.CHAR_2:
					_mc=new Role2();
					break;
				case CharTypeDefine.CHAR_3:
					_mc=new Role3();
					break;
				case CharTypeDefine.CHAR_4:
					_mc=new Role4();
					break;
			}
			addChild(_mc);
			setState(CharStateDefine.Y_DJ)
		}
		
		public function dj()
		{
			switch(_state)
			{
				case CharStateDefine.Y_MV:
					setState(CharStateDefine.Y_DJ);
					break;
				case CharStateDefine.Z_MV:
					setState(CharStateDefine.Z_DJ);
					break;
			}
		}
		
		public function setState(i:int)
		{
			if(_state==i)
			{
				return;
			}
			
			_state=i;
			switch(_state)
			{
				case CharStateDefine.Y_DJ:
					_mc.gotoAndStop(1);
					break;
				case CharStateDefine.Y_MV:
					_mc.gotoAndStop(2);
					break;
				case CharStateDefine.Z_DJ:
					_mc.gotoAndStop(3);
					break;
				case CharStateDefine.Z_MV:
					_mc.gotoAndStop(4);
					break;
			}
		}
		
		public function yZL()
		{
			switch(_state)
			{
				case CharStateDefine.Y_DJ:
					setState(CharStateDefine.Y_MV);
					break;
				case CharStateDefine.Z_DJ:
					setState(CharStateDefine.Z_MV);
					break;
			}
		}
		
		public function destroy()
		{
			if(_mc&&this.contains(_mc))
			{
				removeChild(_mc);
				_mc=null;
			}
		}
	}
}